package org.jeie.actions;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.image.BufferedImage;

import org.jeie.main.Action;
import org.jeie.messages.Messages;

public class LineAction implements Action {
	public Point p1;
	public Point p2;
	public Color color;
	public int size;

	public LineAction(Point p1, Point p2, Color color, int size) {
		this.p1 = p1;
		this.p2 = p2;
		this.color = color;
		this.size = size;
	}

	public BufferedImage apply(BufferedImage img) {
		Graphics2D g = img.createGraphics();
		g.setStroke(new BasicStroke(
			size,
			BasicStroke.CAP_ROUND,
			BasicStroke.JOIN_ROUND));
		g.setColor(color);
		g.drawLine(p1.x, p1.y, p2.x, p2.y);
		return img;
	}

	public String getName() {
		return Messages.getString("Action.Line"); //$NON-NLS-1$
	}
}
